package no.ntnu.idi.deid.statistical.tfidf;

import java.io.File;
import java.util.TreeMap;

import no.ntnu.idi.deid.documentunits.Document;
import no.ntnu.idi.deid.preprocessor.Documents;
import no.ntnu.idi.deid.preprocessor.wordcount.CountManager;
import no.ntnu.idi.deid.preprocessor.wordcount.Entity;

public class TokenDocumentFrequency extends DocumentFrequency {

	public TokenDocumentFrequency(Documents documents) {
		super(documents);
	}
	
	public TokenDocumentFrequency(File file) {
		super(file);
	}
	
	protected void generateMap(Documents documents) {
		TreeMap<String, Integer> tfMap = new TreeMap<String, Integer>();
		for (Document doc : documents) {
			CountManager wcm = doc.getWordCountManager();
			for (Entity entity : wcm.getSortedWords()) {
				insert(entity.getString(), tfMap);
			}
		}
		generateTfIdfMap(tfMap);
	}
}
